/**
 *
 * @param {Number | String} value 设备的状态值
 * @returns {String} 设备状态的文字描述
 */
const statusTextConvert = (
  status: number,
  isOnline: boolean
): string | undefined => {
  if (isOnline) {
    if (status == 0) {
      return '待机中';
    } else if (status === 1) {
      return '工作中';
    } else if (status === 2) {
      return '睡眠中';
    }
  } else {
    return '设备离线';
  }
};

/**
 *
 * @param {Number | String} value 设备的状态值
 * @returns {String} 设备状态的文字描述
 */
const runningTextConvert = (value: number): string => {
  // 1=离线 2=待机 3=烹饪中 4=保温中 5=预约中
  const data: { [key: string]: string } = {
    1: '工作',
  };
  return data[value];
};

// 故障标题
const faultTextConvert = (value: number): string => {
  const data: { [key: string]: string } = {
    1: 'E01 传感器短路',
    2: 'E02 传感器开路',
    3: 'E03 发热管加热异常',
  };
  return data[value];
};
// 故障详情
const faultTextdescription = (value: number): string => {
  // 1=离线 2=待机 3=烹饪中 4=保温中 5=预约中
  const data: { [key: string]: string } = {
    1: '联系客服人员，送至维修点维修',
    2: '联系客服人员，送至维修点维修',
    3: '联系客服人员，送至维修点维修',
  };
  return data[value];
};

/**
 * @description 按钮文字过滤器
 * @param {Number} status 运行状态 0-待机 1-运行中 2-睡眠中
 * @param {Number } 
 * @returns {String} 设备状态的文字描述
 */
const btnFitersText = (
  status: number,
  prompt: number
): string => {
  if (prompt === 1) {
    return '取消';
  } else {
    if (status === 1) {
      return '结束运行';
    } else if (status === 2) {
      return '开启';
    } else {
      return '开始运行';
    }
  }
 
};


interface TimeTemp {
  time: number;
  temperature: number;
}
const timeTempToMode = (value: number): TimeTemp | undefined => {
  // 0-自定义 1-鸡翅 2-鸡腿 3-红薯 4-蛋挞 5-大虾 6-鱼 7-牛排 8-蛋糕 9-薯条
  const data: { [key: number]: TimeTemp } = {
    0: { time: 15, temperature: 180 },
    1: { time: 18, temperature: 180 },
    2: { time: 22, temperature: 180 },
    3: { time: 32, temperature: 180 },
    4: { time: 15, temperature: 160 },
    5: { time: 15, temperature: 180 },
    6: { time: 15, temperature: 150 },
    7: { time: 15, temperature: 180 },
    8: { time: 30, temperature: 160 },
    9: { time: 15, temperature: 190 },
  };
  return data[value];
};

export {
  timeTempToMode,
  btnFitersText,
  statusTextConvert,
  runningTextConvert,
  faultTextConvert,
  faultTextdescription
};
